<?php

require_once("dao/tournaments_dao.php");

class addTournament_controller extends abstract_controller_secure { //sjekk.. {

function prepare_model($request_params, Smarty $smarty_obj) { 
		if(!$_SESSION['admin']) {
			echo "Du har ingenting her aa gjoere";
			exit();
		}
		$name =  isset($_POST['name'])  ? htmlentities($_POST['name']) : "";
		$rules = isset($_POST['rules']) ? htmlentities($_POST['rules']): "";
		$info =  isset($_POST['info'])  ? htmlentities($_POST['info']) : "";
		$numberofplayers =  isset($_POST['numberofplayers'])  ? htmlentities($_POST['numberofplayers']) : "";
			
		
		if (!(empty($name) || empty($rules) || empty($info)|| empty($numberofplayers))){
			tournaments_dao::addTournament($name,$rules,$info,$numberofplayers);
			$smarty_obj->assign("newTournament", true);
		}
		
		$smarty_obj->assign("page_title", "Kontrollpanel");
	}

}
?>